#!/bin/bash


basepath=$(cd `dirname $0`; pwd)
scriptName=${0##*/}
scriptName=$basepath/$scriptName
cd $basepath
clear
hosts=$(egrep "^inventory " $basepath/ansible.cfg|awk {'print $3'})
roles=$(egrep "^roles_path" $basepath/ansible.cfg|awk {'print $3'})
cat $hosts
read -p "输入主机:" host
ls --color $roles
read -p "输入role:" role
ansible-playbook $roles/$role/site.yml -e host=$host -e role=$role
echo "完整命令:cd $basepath && ansible-playbook $roles/$role/site.yml -e host=$host -e role=$role"
